原贴地址：[http://blog.leanote.com/post/dawnmagnet/lc149](http://blog.leanote
.com/post/dawnmagnet/lc149)
# 题目
<p>给你一个数组 <code>points</code> ，其中 <code>points[i] = [x<sub>i</sub>, 
y<sub>i</sub>]</code> 表示 <strong>X-Y</strong> 
平面上的一个点。求最多有多少个点在同一条直线上。</p>
<p>&nbsp;</p>
<p><strong>示例 1：</strong></p>
<img style="width: 300px; height: 294px;" 
src="https://assets.leetcode.com/uploads/2021/02/25/plane1.jpg" alt="">
<pre><strong>输入：</strong>points = [[1,1],[2,2],[3,3]]
<strong>输出：</strong>3
</pre>
<p><strong>示例 2：</strong></p>
<img style="width: 300px; height: 294px;" 
src="https://assets.leetcode.com/uploads/2021/02/25/plane2.jpg" alt="">
<pre><strong>输入：</strong>points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
<strong>输出：</strong>4
</pre>
<p>&nbsp;</p>
<p><strong>提示：</strong></p>
<ul>
    <li><code>1 &lt;= points.length &lt;= 300</code></li>
    <li><code>points[i].length == 2</code></li>
    <li><code>-10<sup>4</sup> &lt;= x<sub>i</sub>, y<sub>i</sub> &lt;= 
    10<sup>4</sup></code></li>
    <li><code>points</code> 中的所有点 <strong>互不相同</strong></li>
</ul>
# 思路分析
学过一点点数学的人都知道，两点确定一条直线，且两点一定共这条直线。
所以我们没法判断两个点的关系，我们只能判断三个点的关系。
所以我们使用三次遍历的方式，来确定两条直线确定的一条直线是否会被第三个点穿过
。
# C++代码
```cpp
#define REP(i, j) for (int i = 0; i < j; ++i)
class Solution {
public:
    int maxPoints(vector<vector<int>>& points) {
        int n = points.size();
        if (n <= 2) return n;
        int res = 0;
        REP(i, n) REP(j, n) if (i != j) {